import request from '@/utils/http'

// 获取实体店信息
export function getStoreInfoAPI(userId) {
  return request({
    url: '/store/selectStoreByUserId',
    method: 'get',
    params: { userId }
  })
}

//根据实体店id获取实体店信息
export function selectStoreByIdAPI(storeId) {
  return request({
    url: '/store/selectStoreById',
    method: 'get',
    params: { storeId }
  })
}

// 更新实体店信息
export function updateStoreInfoAPI(data) {
  return request({
    url: '/store/updateStore',
    method: 'put',
    data: data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  })
}

//更新实体店商户登录信息
export function updateUserApi(params) {
  return request({
    url: '/user/updateUser',
    method: 'put',
    params: params,
  })
}

// 获取实体店地址列表
export function getAddressListAPI(id) {
  console.log(id);

  return request({
    url: '/address/findByUserId',
    method: 'get',
    params: { id }
  })
}

// 新增地址
export function addAddressAPI(data) {
  return request({
    url: '/address',
    method: 'post',
    data: data
  })
}

// 修改地址
export function updateAddressAPI(data) {
  return request({
    url: '/address',
    method: 'put',
    data: data
  })
}

// 删除地址
export function deleteAddressAPI(id) {
  return request({
    url: '/address/deleteAddress',
    method: 'delete',
    params: { id }
  })
}

// 获取实体店商品列表
export function getGoodsListAPI(userId) {
  return request({
    url: '/goods/selectGoodsList',
    method: 'get',
    params: { userId }
  })
}

// 新增商品
export function addGoodAPI(userId, data) {
  return request({
    url: '/goods/insertGoods',
    method: 'post',
    params: { userId },
    data: data
  })
}

// 编辑商品
export function editGoodAPI(data) {
  return request({
    url: '/goods/updateGoods',
    method: 'put',
    data: data
  })
}

// 删除商品
export function deleteGoodAPI(goodsId) {
  return request({
    url: '/goods/deleteGoods',
    method: 'delete',
    params: { goodsId }
  })
}

// 获取款式列表
export function getStyleListAPI() {
  return request({
    url: '/style/getStyleList',
    method: 'get',
    params: {}
  })
}

// 获取SKU列表
export function getSkuListAPI(userId) {
  return request({
    url: '/sku/selectByUserId',
    method: 'get',
    params: { userId }
  })
}
// 获取SKU列表
// export function getSkuListAPI(goodId) {
//   return request({
//     url: '/sku/selectByGoodId',
//     method: 'get',
//     params: { goodId }
//   })
// }

//新增商品的sku
export function addSkuAPI(data) {
  return request({
    url: '/sku/insertGoodSku',
    method: 'post',
    data: data
  })
}

//修改商品的sku
export function updateSkuAPI(data) {
  return request({
    url: '/sku/updateGoodSku',
    method: 'put',
    data: data
  })
}

//删除商品sku
export function deleteSkuAPI(skuId) {
  return request({
    url: '/sku/deleteGoodsSku',
    method: 'delete',
    params: { skuId }
  })
}


// 获取实体店订单列表
export function getOrderListAPI(storeId, orderNum) {
  return request({
    url: '/order/getOrderList',
    method: 'get',
    params: { storeId, orderNum }
  })
}

// 更新实体店订单
export function updateOrderAPI(orderId, status) {
  return request({
    url: '/order/updateOrder',
    method: 'put',
    data: { orderId, status },
    headers: {
      "Content-Type": "multipart/form-data"
    }
  })
}

//获取采购批发订单列表
export function getPurchaseListAPI(params) {
  return request({
    url: '/purchase',
    method: 'get',
    params: params
  })
}

//更新采购批发订单信息
export function updatePurchaseAPI(data) {
  return request({
    url: '/purchase/updatePurchase',
    method: 'put',
    params: data
  })
}

//获取我的众筹定制参与列表
export function getUserCrowdFundingListAPI(userId) {
  return request({
    url: '/project/selectProjectStore',
    method: 'get',
    params: { userId }
  })
}

//退出众筹
export function quitCrowdFundingAPI(params) {
  return request({
    url: '/project/quitProject',
    method: 'put',
    params: params
  })
}